{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'win32'"
      ]
     },
     "execution_count": 1,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import sys #我在使用的底层操作系统\n",
    "sys.platform"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'C:\\\\Users\\\\Hackintosh'"
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import os #代码所在位置\n",
    "os.getcwd()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "datetime.date(2020, 10, 15)"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import datetime #使用datetime模块查询日期\n",
    "datetime.date.today()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "10"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import datetime #可以单独查询月份\n",
    "datetime.date.today().month"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'2020-10-15'"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import datetime #还可以将日期转化为一个字符串\n",
    "datetime.date.isoformat(datetime.date.today())"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'16:49'"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import time #可以使用time模块的strftime函数查询时间\n",
    "time.strftime(\"%H:%M\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "ename": "SyntaxError",
     "evalue": "invalid character in identifier (<ipython-input-7-79c9a38a19a4>, line 4)",
     "output_type": "error",
     "traceback": [
      "\u001b[1;36m  File \u001b[1;32m\"<ipython-input-7-79c9a38a19a4>\"\u001b[1;36m, line \u001b[1;32m4\u001b[0m\n\u001b[1;33m    if condition =='不太开心'：\u001b[0m\n\u001b[1;37m                         ^\u001b[0m\n\u001b[1;31mSyntaxError\u001b[0m\u001b[1;31m:\u001b[0m invalid character in identifier\n"
     ]
    }
   ],
   "source": [
    "if today == 'Saturday':\n",
    "    print('开心的周末开始啦！')\n",
    "elif today == 'Sunday':\n",
    "    if condition =='不太开心'： #书里范例是假设有condition这个变量，但实际我的代码没有\n",
    "        print('看看剧，放松一下吧~')\n",
    "    else:\n",
    "        print('休息时间')\n",
    "else:\n",
    "    print('学习学习学习！')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "ename": "NameError",
     "evalue": "name 'today' is not defined",
     "output_type": "error",
     "traceback": [
      "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[1;31mNameError\u001b[0m                                 Traceback (most recent call last)",
      "\u001b[1;32m<ipython-input-8-a05a47e1b2c1>\u001b[0m in \u001b[0;36m<module>\u001b[1;34m\u001b[0m\n\u001b[0;32m      3\u001b[0m \u001b[0mright_this_minute\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mdatetime\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mtoday\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mminute\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m      4\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m----> 5\u001b[1;33m \u001b[1;32mif\u001b[0m \u001b[0mtoday\u001b[0m \u001b[1;33m==\u001b[0m \u001b[1;34m'Saturday'\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m      6\u001b[0m     \u001b[0mprint\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;34m'开心的周末开始啦！'\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m      7\u001b[0m \u001b[1;32melif\u001b[0m \u001b[0mtoday\u001b[0m \u001b[1;33m==\u001b[0m \u001b[1;34m'Sunday'\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
      "\u001b[1;31mNameError\u001b[0m: name 'today' is not defined"
     ]
    }
   ],
   "source": [
    "from datetime import datetime\n",
    "odds = [1,3,5,7,9,11,13,15,17,19,21,23,25,27,29,31,35,37,39,41,43,45,47,49,51,53,55,57,59]\n",
    "right_this_minute = datetime.today().minute\n",
    "# 又忘记添加today变量了\n",
    "if today == 'Saturday':\n",
    "    print('开心的周末开始啦！')\n",
    "elif today == 'Sunday':\n",
    "    if right_this_minute == 'odds':\n",
    "        print('看看剧，放松一下吧~')\n",
    "    else:\n",
    "        print('休息时间')\n",
    "else:\n",
    "    print('学习学习学习！')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "学习学习学习！\n"
     ]
    }
   ],
   "source": [
    "from datetime import datetime\n",
    "odds = [1,3,5,7,9,11,13,15,17,19,21,23,25,27,29,31,35,37,39,41,43,45,47,49,51,53,55,57,59]\n",
    "right_this_minute = datetime.today().minute\n",
    "today = datetime.today().weekday #新增today变量\n",
    "\n",
    "if today == 'Saturday':\n",
    "    print('开心的周末开始啦！')\n",
    "elif today == 'Sunday':\n",
    "    if right_this_minute == 'odds':\n",
    "        print('看看剧，放松一下吧~')\n",
    "    else:\n",
    "        print('休息时间')\n",
    "else:\n",
    "    print('学习学习学习！')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "1\n",
      "2\n",
      "3\n"
     ]
    }
   ],
   "source": [
    "for i in [1,2,3]:\n",
    "    print(i)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "p\n",
      "y\n",
      "t\n",
      "h\n",
      "o\n",
      "n\n",
      " \n",
      "很\n",
      "好\n",
      "玩\n"
     ]
    }
   ],
   "source": [
    "for i in \"python 很好玩\": #原来中文也可以\n",
    "    print(i)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "好想出去玩\n",
      "好想出去玩\n",
      "好想出去玩\n"
     ]
    }
   ],
   "source": [
    "for num in range(3):\n",
    "    print('好想出去玩')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "99 bottle of beer on the wall.\n",
      "99 bottle of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "98 bottle of beer on the wall.\n",
      "\n",
      "98 bottle of beer on the wall.\n",
      "98 bottle of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "97 bottle of beer on the wall.\n",
      "\n",
      "97 bottle of beer on the wall.\n",
      "97 bottle of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "96 bottle of beer on the wall.\n",
      "\n",
      "96 bottle of beer on the wall.\n",
      "96 bottle of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "95 bottle of beer on the wall.\n",
      "\n",
      "95 bottle of beer on the wall.\n",
      "95 bottle of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "94 bottle of beer on the wall.\n",
      "\n",
      "94 bottle of beer on the wall.\n",
      "94 bottle of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "93 bottle of beer on the wall.\n",
      "\n",
      "93 bottle of beer on the wall.\n",
      "93 bottle of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "92 bottle of beer on the wall.\n",
      "\n",
      "92 bottle of beer on the wall.\n",
      "92 bottle of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "91 bottle of beer on the wall.\n",
      "\n",
      "91 bottle of beer on the wall.\n",
      "91 bottle of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "90 bottle of beer on the wall.\n",
      "\n",
      "90 bottle of beer on the wall.\n",
      "90 bottle of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "89 bottle of beer on the wall.\n",
      "\n",
      "89 bottle of beer on the wall.\n",
      "89 bottle of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "88 bottle of beer on the wall.\n",
      "\n",
      "88 bottle of beer on the wall.\n",
      "88 bottle of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "87 bottle of beer on the wall.\n",
      "\n",
      "87 bottle of beer on the wall.\n",
      "87 bottle of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "86 bottle of beer on the wall.\n",
      "\n",
      "86 bottle of beer on the wall.\n",
      "86 bottle of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "85 bottle of beer on the wall.\n",
      "\n",
      "85 bottle of beer on the wall.\n",
      "85 bottle of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "84 bottle of beer on the wall.\n",
      "\n",
      "84 bottle of beer on the wall.\n",
      "84 bottle of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "83 bottle of beer on the wall.\n",
      "\n",
      "83 bottle of beer on the wall.\n",
      "83 bottle of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "82 bottle of beer on the wall.\n",
      "\n",
      "82 bottle of beer on the wall.\n",
      "82 bottle of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "81 bottle of beer on the wall.\n",
      "\n",
      "81 bottle of beer on the wall.\n",
      "81 bottle of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "80 bottle of beer on the wall.\n",
      "\n",
      "80 bottle of beer on the wall.\n",
      "80 bottle of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "79 bottle of beer on the wall.\n",
      "\n",
      "79 bottle of beer on the wall.\n",
      "79 bottle of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "78 bottle of beer on the wall.\n",
      "\n",
      "78 bottle of beer on the wall.\n",
      "78 bottle of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "77 bottle of beer on the wall.\n",
      "\n",
      "77 bottle of beer on the wall.\n",
      "77 bottle of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "76 bottle of beer on the wall.\n",
      "\n",
      "76 bottle of beer on the wall.\n",
      "76 bottle of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "75 bottle of beer on the wall.\n",
      "\n",
      "75 bottle of beer on the wall.\n",
      "75 bottle of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "74 bottle of beer on the wall.\n",
      "\n",
      "74 bottle of beer on the wall.\n",
      "74 bottle of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "73 bottle of beer on the wall.\n",
      "\n",
      "73 bottle of beer on the wall.\n",
      "73 bottle of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "72 bottle of beer on the wall.\n",
      "\n",
      "72 bottle of beer on the wall.\n",
      "72 bottle of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "71 bottle of beer on the wall.\n",
      "\n",
      "71 bottle of beer on the wall.\n",
      "71 bottle of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "70 bottle of beer on the wall.\n",
      "\n",
      "70 bottle of beer on the wall.\n",
      "70 bottle of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "69 bottle of beer on the wall.\n",
      "\n",
      "69 bottle of beer on the wall.\n",
      "69 bottle of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "68 bottle of beer on the wall.\n",
      "\n",
      "68 bottle of beer on the wall.\n",
      "68 bottle of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "67 bottle of beer on the wall.\n",
      "\n",
      "67 bottle of beer on the wall.\n",
      "67 bottle of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "66 bottle of beer on the wall.\n",
      "\n",
      "66 bottle of beer on the wall.\n",
      "66 bottle of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "65 bottle of beer on the wall.\n",
      "\n",
      "65 bottle of beer on the wall.\n",
      "65 bottle of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "64 bottle of beer on the wall.\n",
      "\n",
      "64 bottle of beer on the wall.\n",
      "64 bottle of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "63 bottle of beer on the wall.\n",
      "\n",
      "63 bottle of beer on the wall.\n",
      "63 bottle of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "62 bottle of beer on the wall.\n",
      "\n",
      "62 bottle of beer on the wall.\n",
      "62 bottle of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "61 bottle of beer on the wall.\n",
      "\n",
      "61 bottle of beer on the wall.\n",
      "61 bottle of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "60 bottle of beer on the wall.\n",
      "\n",
      "60 bottle of beer on the wall.\n",
      "60 bottle of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "59 bottle of beer on the wall.\n",
      "\n",
      "59 bottle of beer on the wall.\n",
      "59 bottle of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "58 bottle of beer on the wall.\n",
      "\n",
      "58 bottle of beer on the wall.\n",
      "58 bottle of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "57 bottle of beer on the wall.\n",
      "\n",
      "57 bottle of beer on the wall.\n",
      "57 bottle of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "56 bottle of beer on the wall.\n",
      "\n",
      "56 bottle of beer on the wall.\n",
      "56 bottle of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "55 bottle of beer on the wall.\n",
      "\n",
      "55 bottle of beer on the wall.\n",
      "55 bottle of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "54 bottle of beer on the wall.\n",
      "\n",
      "54 bottle of beer on the wall.\n",
      "54 bottle of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "53 bottle of beer on the wall.\n",
      "\n",
      "53 bottle of beer on the wall.\n",
      "53 bottle of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "52 bottle of beer on the wall.\n",
      "\n",
      "52 bottle of beer on the wall.\n",
      "52 bottle of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "51 bottle of beer on the wall.\n",
      "\n",
      "51 bottle of beer on the wall.\n",
      "51 bottle of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "50 bottle of beer on the wall.\n",
      "\n",
      "50 bottle of beer on the wall.\n",
      "50 bottle of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "49 bottle of beer on the wall.\n",
      "\n",
      "49 bottle of beer on the wall.\n",
      "49 bottle of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "48 bottle of beer on the wall.\n",
      "\n",
      "48 bottle of beer on the wall.\n",
      "48 bottle of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "47 bottle of beer on the wall.\n",
      "\n",
      "47 bottle of beer on the wall.\n",
      "47 bottle of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "46 bottle of beer on the wall.\n",
      "\n",
      "46 bottle of beer on the wall.\n",
      "46 bottle of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "45 bottle of beer on the wall.\n",
      "\n",
      "45 bottle of beer on the wall.\n",
      "45 bottle of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "44 bottle of beer on the wall.\n",
      "\n",
      "44 bottle of beer on the wall.\n",
      "44 bottle of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "43 bottle of beer on the wall.\n",
      "\n",
      "43 bottle of beer on the wall.\n",
      "43 bottle of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "42 bottle of beer on the wall.\n",
      "\n",
      "42 bottle of beer on the wall.\n",
      "42 bottle of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "41 bottle of beer on the wall.\n",
      "\n",
      "41 bottle of beer on the wall.\n",
      "41 bottle of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "40 bottle of beer on the wall.\n",
      "\n",
      "40 bottle of beer on the wall.\n",
      "40 bottle of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "39 bottle of beer on the wall.\n",
      "\n",
      "39 bottle of beer on the wall.\n",
      "39 bottle of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "38 bottle of beer on the wall.\n",
      "\n",
      "38 bottle of beer on the wall.\n",
      "38 bottle of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "37 bottle of beer on the wall.\n",
      "\n",
      "37 bottle of beer on the wall.\n",
      "37 bottle of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "36 bottle of beer on the wall.\n",
      "\n",
      "36 bottle of beer on the wall.\n",
      "36 bottle of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "35 bottle of beer on the wall.\n",
      "\n",
      "35 bottle of beer on the wall.\n",
      "35 bottle of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "34 bottle of beer on the wall.\n",
      "\n",
      "34 bottle of beer on the wall.\n",
      "34 bottle of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "33 bottle of beer on the wall.\n",
      "\n",
      "33 bottle of beer on the wall.\n",
      "33 bottle of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "32 bottle of beer on the wall.\n",
      "\n",
      "32 bottle of beer on the wall.\n",
      "32 bottle of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "31 bottle of beer on the wall.\n",
      "\n",
      "31 bottle of beer on the wall.\n",
      "31 bottle of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "30 bottle of beer on the wall.\n",
      "\n",
      "30 bottle of beer on the wall.\n",
      "30 bottle of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "29 bottle of beer on the wall.\n",
      "\n",
      "29 bottle of beer on the wall.\n",
      "29 bottle of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "28 bottle of beer on the wall.\n",
      "\n",
      "28 bottle of beer on the wall.\n",
      "28 bottle of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "27 bottle of beer on the wall.\n",
      "\n",
      "27 bottle of beer on the wall.\n",
      "27 bottle of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "26 bottle of beer on the wall.\n",
      "\n",
      "26 bottle of beer on the wall.\n",
      "26 bottle of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "25 bottle of beer on the wall.\n",
      "\n",
      "25 bottle of beer on the wall.\n",
      "25 bottle of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "24 bottle of beer on the wall.\n",
      "\n",
      "24 bottle of beer on the wall.\n",
      "24 bottle of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "23 bottle of beer on the wall.\n",
      "\n",
      "23 bottle of beer on the wall.\n",
      "23 bottle of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "22 bottle of beer on the wall.\n",
      "\n",
      "22 bottle of beer on the wall.\n",
      "22 bottle of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "21 bottle of beer on the wall.\n",
      "\n",
      "21 bottle of beer on the wall.\n",
      "21 bottle of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "20 bottle of beer on the wall.\n",
      "\n",
      "20 bottle of beer on the wall.\n",
      "20 bottle of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "19 bottle of beer on the wall.\n",
      "\n",
      "19 bottle of beer on the wall.\n",
      "19 bottle of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "18 bottle of beer on the wall.\n",
      "\n",
      "18 bottle of beer on the wall.\n",
      "18 bottle of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "17 bottle of beer on the wall.\n",
      "\n",
      "17 bottle of beer on the wall.\n",
      "17 bottle of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "16 bottle of beer on the wall.\n",
      "\n",
      "16 bottle of beer on the wall.\n",
      "16 bottle of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "15 bottle of beer on the wall.\n",
      "\n",
      "15 bottle of beer on the wall.\n",
      "15 bottle of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "14 bottle of beer on the wall.\n",
      "\n",
      "14 bottle of beer on the wall.\n",
      "14 bottle of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "13 bottle of beer on the wall.\n",
      "\n",
      "13 bottle of beer on the wall.\n",
      "13 bottle of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "12 bottle of beer on the wall.\n",
      "\n",
      "12 bottle of beer on the wall.\n",
      "12 bottle of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "11 bottle of beer on the wall.\n",
      "\n",
      "11 bottle of beer on the wall.\n",
      "11 bottle of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "10 bottle of beer on the wall.\n",
      "\n",
      "10 bottle of beer on the wall.\n",
      "10 bottle of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "9 bottle of beer on the wall.\n",
      "\n",
      "9 bottle of beer on the wall.\n",
      "9 bottle of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "8 bottle of beer on the wall.\n",
      "\n",
      "8 bottle of beer on the wall.\n",
      "8 bottle of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "7 bottle of beer on the wall.\n",
      "\n",
      "7 bottle of beer on the wall.\n",
      "7 bottle of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "6 bottle of beer on the wall.\n",
      "\n",
      "6 bottle of beer on the wall.\n",
      "6 bottle of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "5 bottle of beer on the wall.\n",
      "\n",
      "5 bottle of beer on the wall.\n",
      "5 bottle of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "4 bottle of beer on the wall.\n",
      "\n",
      "4 bottle of beer on the wall.\n",
      "4 bottle of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "3 bottle of beer on the wall.\n",
      "\n",
      "3 bottle of beer on the wall.\n",
      "3 bottle of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "2 bottle of beer on the wall.\n",
      "\n",
      "2 bottle of beer on the wall.\n",
      "2 bottle of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "1 bottle of beer on the wall.\n",
      "\n",
      "1 bottle of beer on the wall.\n",
      "1 bottle of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "No more bottles of beer on the wall.\n",
      "\n"
     ]
    }
   ],
   "source": [
    "word = \"bottle\" #在这里\n",
    "for beer_num in range(99,0,-1):\n",
    "    print(beer_num,word,\"of beer on the wall.\")\n",
    "    print(beer_num,word,\"of beer.\") #这里的word是上面的word变量\n",
    "    print(\"Take one down.\")\n",
    "    print(\"Pass it around.\")\n",
    "    if beer_num == 1:\n",
    "        print(\"No more bottles of beer on the wall.\")\n",
    "    else:\n",
    "        new_num = beer_num - 1\n",
    "        if new_num == 1:\n",
    "            word = \"bottle\" #这一步是让最后一行的歌词没有语法错误\n",
    "        print(new_num,word,\"of beer on the wall.\")\n",
    "    print()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
